fix(mcp): keep search index type in vector hydration#984
Conversation
Signed-off-by: rudi193-cmd <rudi193@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df486d4b9e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| si_ids = list(similarity_by_si_id.keys()) | ||
| search_index_rows = await self._fetch_search_index_rows_by_ids(si_ids) | ||
| si_keys = list(similarity_by_si_key.keys()) | ||
| search_index_rows = await self._fetch_search_index_rows_by_ids(si_keys) |
There was a problem hiding this comment.
Carry typed keys through hybrid fusion
When this vector path is invoked from _search_hybrid (retrieval_mode=hybrid), the typed duplicate ids returned here are immediately collapsed because hybrid fusion still stores rows_by_id, fts_scores, vec_scores, and fused_scores by bare row.id. A query whose vector hits include both entity:4:0 and relation:4:0 will now return both in vector mode, but hybrid mode overwrites one of them, so the collision fix does not apply to MCP/API hybrid searches. Please carry (row.type, row.id) through the hybrid fusion maps as well.
Useful? React with 👍 / 👎.
|
Thanks for the PR! This has been fixed in #986 but if you continue to find trouble with it we are happy to accept your PRs. |
Fixes #982.
Summary
(type, id)instead of bareid, so entity/relation/observation rows with the same search_index id no longer overwrite each other.WHERE id IN (...)query shape and apply type discrimination in Python, matching the existing filtered-search guard.entity:4:0andrelation:4:0both hydrating successfully.Test plan
uv run pytest tests/repository/test_vector_threshold.py tests/repository/test_vector_pagination.pyuv run ruff format src/basic_memory/repository/search_repository_base.py tests/repository/test_vector_threshold.py tests/repository/test_vector_pagination.pyuv run ruff check src/basic_memory/repository/search_repository_base.py tests/repository/test_vector_threshold.py tests/repository/test_vector_pagination.pyReplaces #983, which had the same patch but missed the DCO sign-off trailer.